package com.example.springcloud.service;

import com.example.springcloud.entities.CommonResult;
import com.example.springcloud.entities.Payment;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;


@Component // 不要忘记添加，不要忘记添加
public class DeptClientServiceFallbackFactory implements FallbackFactory<PaymentFeignService> {
    @Override
    public PaymentFeignService create(Throwable throwable) {
        return new PaymentFeignService() {

            @Override
            public CommonResult<Payment> getPaymentById(Long id) {
                return new CommonResult(-1, new Payment().setId(id).setSerial("该ID：" + id + "没有没有对应的信息,Consumer客户端提供的降级信息,此刻服务Provider已经关闭").toString());
            }

            @Override
            public String paymentFeignTimeout() {
                return "服务降级处理是在客户端实现完成的，与服务端没有关系";
            }
        };
    }
}
